package com.huang.wangpan.controller;

import com.huang.wangpan.strategy.StrategyConfig;
import com.huang.wangpan.strategy.process.CommonProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class DataController {

    @Autowired
    StrategyConfig strategyConfig;

    @RequestMapping("/getFile*")
    public void index(HttpServletRequest request,
                      HttpServletResponse response) {
        String method = request.getParameter("method");
        // 使用策略模式+枚举对应的操作
        // 获取实例
        CommonProcess commonProcess = strategyConfig.getBean(method);
        // 实际处理
        commonProcess.process(method,request,response);
    }
}
